%{
%}

%token IDENTIFIER FLAG COLONEQ QUOTED DOTDOTDOT FUNC ARROW
%%
statements: statement
	| statements ';' statement

statement: decl
	| FUNC IDENTIFIER functype

decl: IDENTIFIER COLONEQ pipe
	| pipe

pipe: call
	| pipe '|' call

call: IDENTIFIER options args

options:
	| optionlist

optionlist: option
	| optionlist option

option: FLAG '=' expr
	| FLAG

args: 
	| expr
	| expr arglist

arglist: expr
	| FLAG
	| arglist expr

expr: IDENTIFIER
	| QUOTED
	| '$' IDENTIFIER
	| '(' options args ')'

functype: flagtypes types ARROW type

flagtypes: FLAG
	| FLAG '=' type

types:
	| typelist

typelist: type
	| typelist type

type: IDENTIFIER
%%
/*

func foo -g=string -quiet=bool -verbose string fd -> fd {
}

func walk -bs=int string -> fs {
	(ok f) := walk -bs=56 /usr/rog
	quiet ::= $ok
	= filter $f
}
FuncType = { flag "=" Type } { Type } [ "..." ] "]" } { Type } "->" Type
Type = identifier

Statements = Statement { ";" StatementList }
Statement = Decl
Decl = [ IdentifierList ":=" ] Pipe
IdentifierList = identifier { "," identifier }
Pipe = Call { "|" Call }
Call = name Arguments
Arguments = { Option } [ Expr { Expr | flag } ]
Option = flag "=" Expr | flag
Expr = identifier
	| DOTDOTDOT
	| string_lit
	| "(" Arguments ")"		// XXX maybe

string_lit =  'rc style string'
		"string with go escapes"
		"
		|string with indent
		"
*/

